import React, { useState } from 'react';
import { Select, Input, Upload, message, Button } from 'antd';
import './tiao.less'
import { UploadOutlined } from '@ant-design/icons';
import {jipoint} from '../../api/Student'
export default function Tiao(props) {
  let {close,xcon}=props
  console.log(xcon);
  
  const { Option } = Select
  const { TextArea } = Input;
  //select框的值
  let [select,setselect]=useState('')
  //积分
  let [ji,setji]=useState('')
  //原因
  let [yuan,setyuan]=useState("")
  const fileprops = {
    name: 'file',
    action: 'http:localhost:4000',
    headers: {
      authorization: 'authorization-text',
    },
    onChange(info) {
      if (info.file.status !== 'uploading') {
        console.log(info.file, info.fileList);
      }
      if (info.file.status === 'done') {
        message.success(`${info.file.name} file uploaded successfully`);
      } else if (info.file.status === 'error') {
        message.error(`${info.file.name} file upload failed.`);
      }
    },
  };
  function handleChange(value) {
    console.log(`selected ${value}`);
    setselect(value)
  }
  return (
    <div className="tiao">
      <div className="tiaocon">
        <div className="one">
          <span className="red">*</span>
          <span className="du">调整幅度:</span>
          <Select defaultValue="请选择" style={{ width: 120 }} onChange={handleChange}>
            <Option value="增加">增加</Option>
            <Option value="减少">减少</Option>
          </Select>
          <Input onChange={(e)=>{
            console.log(e.target.value);
            setji(e.target.value)
          }}/>
          <span>积分</span>
        </div>
        <div className="two">
          <span className="red">*</span>
          <span className="du">调整原因:</span>
          <TextArea rows={4} placeholder="请输入内容" maxLength={6} onChange={(e)=>{
            setyuan(e.target.value)
          }}/>
        </div>
        <div className="three">
          <span>证据：</span>
          <Upload {...fileprops}>
            <Button  icon={<UploadOutlined />} type="primary">上传</Button>
          </Upload>,
        </div>
      </div>
      <div className="but">
      <Button type="primary" onClick={close}>取消</Button>
      <Button type="primary" onClick={()=>{
          jipoint({number:xcon.number,type:select,point:ji,change:yuan}).then((res)=>{
            console.log(res);
            
          })
      }}>确定</Button>
      </div>
    </div>
  )
}
